
package com.joysuch.wwyt.core.service.impl;

import com.joysuch.wwyt.core.entity.BaseLoginAccount;
import com.joysuch.wwyt.core.repository.BaseLoginAccountDao;
import com.joysuch.wwyt.core.service.UserShiroService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
public class UserShiroServiceImpl implements UserShiroService {

    private BaseLoginAccountDao dao;

    @Autowired
    public void setDao(BaseLoginAccountDao dao) {
        this.dao = dao;
    }

    @Override
    public BaseLoginAccount findByUserName(String username) {
        return dao.findFirstByUserName(username);
    }

    @Override
    public BaseLoginAccount get(Long id) {
        return dao.findById(id);
    }

    @Override
    public BaseLoginAccount findByUserNameAndCompanyCode(String username, String companyCode) {
        return dao.findFirstByUserNameAndOrgCodeLike(username, companyCode + "%");
    }

}
